<?php
class ProjectTag extends Zend_Db_Table{
	protected $_name ="project_tag";
	protected $_primary = 'id';

     //根据file_id 查询projecttag
	public function getprojecttagByid($file_id){
		$select = $this->select();
		$select->where("id=".$file_id);
		return $this->fetchAll($select)->toArray();
	}

	//根据file_id 查询projecttag
    public function getprojecttagByproject_id($file_id){
		$select = $this->select();
		$select->where("project_id=".$file_id);
		return $this->fetchAll($select)->toArray();
    }

	//根据tag_id 查询projecttag
    public function getprojecttagBytag_id($tag_id,$page,$perpage){
		$select = $this->select();
		$select->where("tag_id=".$tag_id);
        if($page!=9999){
			$select->limitPage($page,$perpage);
		}
		return $this->fetchAll($select)->toArray();
    }

    public function delprojecttagByprojectid($project_id,$tag_id){
		$where = "project_id=".$project_id." and tag_id=".$tag_id;
		$this->delete($where);
		return true;
    }
	
	public function delProjectTagByProject_id($project_id){
		$where = "project_id=".$project_id;
		$this->delete($where);
		return true;
	}

	//更新projecttag
    public function updateprojecttagByid($array,$file_id){
		$db = $this->getAdapter();
		$where=$db->quoteInto('id = ?', $file_id);
		$this->update($array, $where);
	}
	//删除projecttag
	public function delprojecttagByid($file_id){
		$where = 'id = '. $file_id;
		$this->delete($where);
		return true;
	}
	
	public function getProjectTag(){
		$select = $this->select();
		return $this->fetchAll($select)->toArray();
	}
}
?>
